﻿using System;
using System.Windows.Forms;
using Bifrost;

namespace TextEditor
{


    public class A_InsertTable : A_Action
    {
        public override string ActionName()
        {
            return "inserttable";
        }

        public override A_Action Clone()
        {
            A_InsertTable table = new A_InsertTable();
            table.BaseCloneFrom(this);
            return table;
        }

        public override bool Execute()
        {
            return true;
        }

        public override bool isEnable()
        {
            if (base.myOwnerDocument.CanModify())
            {
                return true;// base.myOwnerDocument.GetInTable(base.myOwnerDocument.Content.CurrentElement) != null ? false : true;
            }
            else
            {
                return (base.myOwnerDocument.CanModify() && base.isEnable());
            }
            //return ((base.myOwnerDocument.CanModify() && base.isEnable()) || base.myOwnerDocument.GetInTable(base.myOwnerDocument.Content.CurrentElement) != null ? false : true);
        }

        public override bool UIExecute()
        {
            InsertTable table = new InsertTable();
            if (table.ShowDialog() == DialogResult.OK)
            {
                base.myOwnerDocument._InsertTable(table.GetRowCount(), table.GetColCount());
                return true;
            }
            return false;
        }
    }
}

